package com.example.onlineeducation.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.example.onlineeducation.base.BaseViewModel
import com.example.onlineeducation.data.entity.LoginUserInfoEntity
import com.example.onlineeducation.repository.UserRepository
import com.yc.jetpacklib.net.YcResult
import kotlinx.coroutines.flow.collectLatest


/**
 * SimpleDes:
 * Creator: Sindi
 * Date: 2021-09-24
 * UseDes:
 */
class ProjectVM : BaseViewModel() {
    private val mUserRepository: UserRepository by lazy { UserRepository(mApiService) }

    private val _mUerInfo = MutableLiveData<YcResult<LoginUserInfoEntity>>()
    val mUerInfo: LiveData<YcResult<LoginUserInfoEntity>> = _mUerInfo

    fun getUerInfo() = ycLaunch {
        mUserRepository.getUserInfo().ycHasLoading().collectLatest { result ->
            _mUerInfo.postValue(result)
        }
    }
}

